//
//  MYFindView.m
//  奇闻
//
//  Created by yangbin on 15/1/2.
//  Copyright (c) 2015年 MingYueGuCheng. All rights reserved.
//

#import "MYFindView.h"
#import "MYSearchBar.h"

@interface MYFindView ()
@property (nonatomic, weak) MYSearchBar *searchBar;

@end
@implementation MYFindView
- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = [UIColor clearColor];
        MYSearchBar *search = [[MYSearchBar alloc] initWithFrame:CGRectMake(0, 0, self.width, 35)];
        search.placeholder = @"大家都在搜索";
        [self addSubview:search];
        self.searchBar = search;
    }
    return self;
}
- (void)setSearchBar:(MYSearchBar *)searchBar
{
    if (nil == _searchBar) {
        _searchBar = searchBar;
        UISwipeGestureRecognizer *swipe = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeAction:)];
        swipe.direction = UISwipeGestureRecognizerDirectionRight | UISwipeGestureRecognizerDirectionDown;
        [self addGestureRecognizer:swipe];
    }
}
#pragma mark - 清扫手势
- (void)swipeAction:(UIGestureRecognizer *)gesture
{
    [UIView animateWithDuration:1.0 animations:^{
        gesture.view.transform = CGAffineTransformTranslate(gesture.view.transform, 160, 0);
    } completion:^(BOOL finished) {
        if (finished) {
            [gesture.view removeFromSuperview];
        }
    }];
}
@end
